package stu.day19_day24.day22;

import java.util.Arrays;
import java.util.Scanner;

public class hw2 {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        int num = Integer.parseInt(str1.split(" ")[0]);
        int len = Integer.parseInt(str1.split(" ")[1]);

        String[] str2 = sc.nextLine().split(" ");
        //Integer[] arr = Arrays.stream(str2).map(Integer::parseInt).toArray(Integer[]::new);
        int[] arr = Arrays.stream(str2).mapToInt(Integer::parseInt).toArray();
        int sum = Arrays.stream(arr).sum();

        if(num>=sum){
            System.out.println("[ ]");
        }else {
            int left = 1;
            int right = Arrays.stream(arr).max().getAsInt()+1;
            while (left<right){
                int mid = (right+left)/2;
                int tep = Arrays.stream(arr).map( o -> o>=mid?mid:o).sum();

                if(tep>num){
                    right = mid;
                }else if(tep<=num){
                    left = mid + 1;
                }
            }
            int h = left-1;


            System.out.println(h);
            System.out.print("[");
            for(int i : arr){
                int rep = i-h>=0?i-h:0;
                System.out.printf("%d,",rep);
            }
            System.out.print("]");



        }





    }
}
